The following example demonstrates how to display the results of various statistical functions in and outside of a grid.

XAML
Copy Code
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">

  <Grid.Resources>

    <xcdg:DataGridCollectionViewSource x:Key="cvs_orderdetails"

                                       Source="{Binding Source={x:Static Application.Current},

                                                        Path=OrderDetails}">

     <xcdg:DataGridCollectionViewSource.StatFunctions>

       <xcdg:CountFunction ResultPropertyName="orderid_count"

                           SourcePropertyName="OrderID"/>

       <xcdg:SumFunction ResultPropertyName="unitprice_sum"

                         SourcePropertyName="UnitPrice"/>

       <xcdg:SumFunction ResultPropertyName="quantity_sum" SourcePropertyName="Quantity"/>

     </xcdg:DataGridCollectionViewSource.StatFunctions>

     <xcdg:DataGridCollectionViewSource.GroupDescriptions>

       <xcdg:DataGridGroupDescription PropertyName="ProductID"/>      

 </xcdg:DataGridCollectionViewSource.GroupDescriptions>

    </xcdg:DataGridCollectionViewSource>

   <xcdg:StatResultConverter x:Key="valueConverter"/>

  </Grid.Resources>

  <DockPanel>

    <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">

      <TextBlock Text="Total Orders: "/>

      <TextBlock Text="{Binding ElementName=OrderDetailsGrid,

                 Path=StatContext.orderid_count}"/>

    </StackPanel>

     <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">

       <TextBlock Text="Average Unit Price: "/>

     <TextBlock Text="{Binding ElementName=OrderDetailsGrid,

                        Path=StatContext.unitprice_average,

                        Converter={StaticResource valueConverter},

                        ConverterParameter=f2}"/>

    </StackPanel>

    <xcdg:DataGridControl x:Name="OrderDetailsGrid"

                          ItemsSource="{Binding Source={StaticResource cvs_orderdetails}}"

                          DockPanel.Dock="Bottom">

      <xcdg:DataGridControl.DefaultGroupConfiguration>

        <xcdg:GroupConfiguration> 

        <xcdg:GroupConfiguration.Footers>

           <DataTemplate>

               <xcdg:StatRow>

               <xcdg:StatCell FieldName="UnitPrice"

                              ResultPropertyName="unitprice_sum"/>

               <xcdg:StatCell FieldName="Quantity"

                              ResultPropertyName="quantity_sum"/>

               <xcdg:StatCell FieldName="OrderID"

                              ResultPropertyName="orderid_count"/>

             </xcdg:StatRow>

           </DataTemplate>

         </xcdg:GroupConfiguration.Footers>

        </xcdg:GroupConfiguration>

      </xcdg:DataGridControl.DefaultGroupConfiguration>    

    </xcdg:DataGridControl>

  </DockPanel>

</Grid>